{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "guided-marine",
   "metadata": {},
   "outputs": [
    {
     "ename": "ImportError",
     "evalue": "cannot import name 'yahoofinance' from 'pyalgotrade.tools' (/root/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pyalgotrade/tools/__init__.py)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mImportError\u001b[0m                               Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-4-97f1774c4a16>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpyalgotrade\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtechnical\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcross\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpyalgotrade\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mplotter\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpyalgotrade\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtools\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0myahoofinance\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      8\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpyalgotrade\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstratanalyzer\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msharpe\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mImportError\u001b[0m: cannot import name 'yahoofinance' from 'pyalgotrade.tools' (/root/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pyalgotrade/tools/__init__.py)"
     ]
    }
   ],
   "source": [
    "import tushare as ts\n",
    "from  pyalgotrade import strategy\n",
    "from pyalgotrade.barfeed import yahoofeed\n",
    "from pyalgotrade.technical import ma\n",
    "from pyalgotrade.technical import cross\n",
    "from pyalgotrade import plotter\n",
    "# from pyalgotrade.tools import yahoofinance\n",
    "from pyalgotrade.stratanalyzer import sharpe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "unusual-bristol",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.doubanio.com/simple\n",
      "Collecting pyalgotrade\n",
      "  Downloading https://pypi.doubanio.com/packages/e1/57/4416e9143ac48ba935f858abd096ec336c15786662e640b16c7854b10480/PyAlgoTrade-0.20.tar.gz (84 kB)\n",
      "\u001b[K     |████████████████████████████████| 84 kB 690 kB/s eta 0:00:011\n",
      "\u001b[?25hRequirement already satisfied: matplotlib in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pyalgotrade) (3.2.2)\n",
      "Requirement already satisfied: numpy in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pyalgotrade) (1.20.1)\n",
      "Requirement already satisfied: python-dateutil in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pyalgotrade) (2.8.0)\n",
      "Requirement already satisfied: pytz in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pyalgotrade) (2021.1)\n",
      "Requirement already satisfied: requests in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pyalgotrade) (2.25.1)\n",
      "Collecting retrying\n",
      "  Downloading https://pypi.doubanio.com/packages/44/ef/beae4b4ef80902f22e3af073397f079c96969c69b2c7d52a57ea9ae61c9d/retrying-1.3.3.tar.gz (10 kB)\n",
      "Requirement already satisfied: scipy in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pyalgotrade) (1.6.1)\n",
      "Requirement already satisfied: six in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pyalgotrade) (1.15.0)\n",
      "Requirement already satisfied: tornado in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pyalgotrade) (6.1)\n",
      "Collecting tweepy\n",
      "  Downloading https://pypi.doubanio.com/packages/67/c3/6bed87f3b1e5ed2f34bd58bf7978e308c86e255193916be76e5a5ce5dfca/tweepy-3.10.0-py2.py3-none-any.whl (30 kB)\n",
      "Collecting ws4py>=0.3.4\n",
      "  Downloading https://pypi.doubanio.com/packages/53/20/4019a739b2eefe9282d3822ef6a225250af964b117356971bd55e274193c/ws4py-0.5.1.tar.gz (51 kB)\n",
      "\u001b[K     |████████████████████████████████| 51 kB 228 kB/s eta 0:00:011\n",
      "\u001b[?25hRequirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from matplotlib->pyalgotrade) (2.4.7)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from matplotlib->pyalgotrade) (1.3.1)\n",
      "Requirement already satisfied: cycler>=0.10 in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from matplotlib->pyalgotrade) (0.10.0)\n",
      "Requirement already satisfied: idna<3,>=2.5 in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from requests->pyalgotrade) (2.10)\n",
      "Requirement already satisfied: chardet<5,>=3.0.2 in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from requests->pyalgotrade) (4.0.0)\n",
      "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from requests->pyalgotrade) (1.26.3)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /root/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from requests->pyalgotrade) (2020.12.5)\n",
      "Collecting requests-oauthlib>=0.7.0\n",
      "  Downloading https://pypi.doubanio.com/packages/a3/12/b92740d845ab62ea4edf04d2f4164d82532b5a0b03836d4d4e71c6f3d379/requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)\n",
      "Collecting oauthlib>=3.0.0\n",
      "  Downloading https://pypi.doubanio.com/packages/e8/5d/9dd1c29e5a786525f6342f6c1d812ed2e37edc653ad297048c1668988053/oauthlib-3.1.1-py2.py3-none-any.whl (146 kB)\n",
      "\u001b[K     |████████████████████████████████| 146 kB 1.3 MB/s eta 0:00:01\n",
      "\u001b[?25hCollecting PySocks!=1.5.7,>=1.5.6\n",
      "  Downloading https://pypi.doubanio.com/packages/8d/59/b4572118e098ac8e46e399a1dd0f2d85403ce8bbaad9ec79373ed6badaf9/PySocks-1.7.1-py3-none-any.whl (16 kB)\n",
      "Building wheels for collected packages: pyalgotrade, ws4py, retrying\n",
      "  Building wheel for pyalgotrade (setup.py) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for pyalgotrade: filename=PyAlgoTrade-0.20-py3-none-any.whl size=159541 sha256=c77e6c69a2340af015e8c196834e90900725590b4ebf5a2296bc4021afb4b0e1\n",
      "  Stored in directory: /root/.cache/pip/wheels/a0/37/93/ea1e39d0e17aa8d7e632286702ff836cc5d39391b389572599\n",
      "  Building wheel for ws4py (setup.py) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for ws4py: filename=ws4py-0.5.1-py3-none-any.whl size=45215 sha256=8ec69e811cb98f42610bb23e80c8f4639f8b13bba3b9f6136fe7f23ff7f54537\n",
      "  Stored in directory: /root/.cache/pip/wheels/12/1a/f3/33e60b0f34d5c564f870788e4ae1664344ba0a4a41fba0c13b\n",
      "  Building wheel for retrying (setup.py) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for retrying: filename=retrying-1.3.3-py3-none-any.whl size=11429 sha256=f0838edb1d740a9e4a1e6957ec70b929e7edde635ed2234d82d15ca10bcf8500\n",
      "  Stored in directory: /root/.cache/pip/wheels/82/53/fb/e0207c5d2cd94fb893d5b9a8397c0d1871c031c1024367a8c8\n",
      "Successfully built pyalgotrade ws4py retrying\n",
      "Installing collected packages: PySocks, oauthlib, requests-oauthlib, ws4py, tweepy, retrying, pyalgotrade\n",
      "Successfully installed PySocks-1.7.1 oauthlib-3.1.1 pyalgotrade-0.20 requests-oauthlib-1.3.0 retrying-1.3.3 tweepy-3.10.0 ws4py-0.5.1\n",
      "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "# pip install pyalgotrade"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
